package com.njit.farm.controller;

import com.njit.farm.model.Order;
import com.njit.farm.model.Result;
import com.njit.farm.service.OrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/order/")
public class OrderController {

    @Resource
    OrderService orderService;

    @RequestMapping(value = "add",method = RequestMethod.POST)
    public Result add(@RequestBody Order order){

        return orderService.add(order);
    }

    @RequestMapping(value = "getByUserId", method = RequestMethod.GET)
    public Result get(@RequestParam("uId") String uId) {
        return orderService.queryByUserId(uId);
    }

    @RequestMapping(value = "delete",method = RequestMethod.GET)
    public Result delete(@RequestParam("oId")String oId){
        return orderService.remove(oId);
    }

}
